// 220119 2030

// Path 模块
// 处理文件路径的小工具
// var path = require("path")

var path = require("path");

console.log("方法】");
console.log('\npath.normalize:');
console.log(path.normalize('..')); // ..
console.log(path.normalize('D:\\Program Files (x86)\\HDPicViewer'));
console.log(path.normalize('D:\\Program Files (x86)\\.')); // D:\Program Files (x86)
console.log(path.normalize('D:\\Program Files (x86)\\..')); // D:\

console.log('\npath.join:');
console.log(path.join('d:', 'Program Files (x86)', "HDPicViewer"));

// path.resolve([from ...], to)
// 将 to 参数解析为绝对路径
console.log('\npath.resolve:');
console.log(path.resolve('fs01.js'));

console.log('\npath.isAbsolute:');
console.log(path.isAbsolute("D:\\Program Files (x86)\\HDPicViewer")); // true
console.log(path.isAbsolute('D:\\Program Files (x86)\\.')); // true
console.log(path.isAbsolute('D:\\Program Files (x86)\\..')); // true
console.log(path.isAbsolute('D:\\Program Files (x86)\\..\\phone')); // true
console.log(path.isAbsolute('.\\')); // false

// path.relative(from, to)
// 将绝对路径转为相对路径
// 返回从 from 到 to 的相对路径
// 用处不大？

console.log('\npath.dirname:');
console.log(path.dirname("D:\\Program Files (x86)\\HDPicViewer")); // D:\Program Files (x86)
console.log(path.dirname("D:\\Program Files (x86)\\HDPicViewer\\PicViewerX64.dll")); // D:\Program Files (x86)\HDPicViewer

console.log('\npath.basename:');
console.log(path.basename("D:\\Program Files (x86)\\HDPicViewer")); // HDPicViewer
console.log(path.basename("D:\\Program Files (x86)\\HDPicViewer\\PicViewerX64.dll")); // PicViewerX64.dll

console.log('\npath.extname:');
console.log(path.extname("D:\\Program Files (x86)\\HDPicViewer")); // 
console.log(path.extname("D:\\Program Files (x86)\\HDPicViewer\\PicViewerX64.dll")); // .dll

// path.parse(pathString)
// path.format(pathObject)

console.log("\n属性：");
console.log(path.sep);
console.log(path.delimiter);
console.log("\npath.posix=");
console.log(path.posix);
console.log("\bpath.win32=");
console.log(path.win32);
